﻿#include <iostream>
#include<vector>
using namespace std;

int main() {
    int n, q, l, r;
    cin >> n >> q;
    vector<long long> ret(n + 1, 0);
    for (int i = 1; i <= n; i++)
    {
        cin >> ret[i];
    }
    vector<long long> dp(n + 1, 0);
    for (int i = 1; i <= n; i++)
    {
        dp[i] = dp[i - 1] + ret[i];
    }
    while (q--)
    {
        cin >> l >> r;
        cout << dp[r] - dp[l - 1] << endl;
    }
    return 0;
}
// 64 位输出请用 printf("%lld")